package cn.gailvlun.gll.presentation.wish;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;

import cn.gailvlun.gll.R;
import cn.gailvlun.gll.databinding.ActivityWishBinding;
import cn.gailvlun.gll.presentation.base.BaseActivity;
import cn.gailvlun.gll.presentation.wish.accepter.AcceptedWishActivity;
import cn.gailvlun.gll.presentation.wish.drawer.WishListActivity;
import cn.gailvlun.gll.presentation.wish.maker.MakeWishActivity;
import cn.gailvlun.gll.presentation.wish.maker.WishExplainActivity;
import cn.gailvlun.gll.util.SPUtil;
import cn.gailvlun.gll.widget.NavigationBarView;



public class WishActivity extends BaseActivity {

    private ActivityWishBinding mBinding;

    public static void openActivity(Context context) {
        Intent intent = new Intent(context, WishActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void initComponent() {
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_wish);
        mBinding.setPresenter(new Presenter());
    }

    @Override
    protected void createHandler() {
        mBinding.nbv.setOnMenuClickListener(new NavigationBarView.OnMenuClickListener() {
            @Override
            public void onMenuClick(NavigationBarView nb) {
                WishListActivity.openActivity(mContext);
            }
        });
        mBinding.nbv.setOnBackListener(new NavigationBarView.OnBackListener() {
            @Override
            public void onBack(NavigationBarView nb) {
                onBackPressed();
            }
        });


    }

    @Override
    protected void loadData(@Nullable Bundle savedInstanceState) {

    }

    public class Presenter {
        public void makeWish() {
            boolean isWishRead = SPUtil.getBoolean(SPUtil.USER, "wishExplain");
            if (isWishRead) {
                MakeWishActivity.openActivity(mContext);
            } else {
                WishExplainActivity.openActivity(mContext);
            }
        }

        public void getWish() {

            AcceptedWishActivity.openActivity(mContext);


        }
    }
}
